package com.sdgakj.interviews.job20180814;

/**
 * @Author: Du Ronghong
 * @Description: 实现Node的遍历
 * @Date: Created in 18:59 2018/8/14
 * @Modified By:
 */
public class Node {

    private int val;
    private Node next;

    public Node(int val) {
        this.val = val;
    }


    public boolean hasNext(Node head) {
        if (head == null) {
            return false;
        }
        return head.next != null;
    }

    public void Iterator(Node node) {
        if (node == null) {
            throw new NullPointerException("Node is null");
        }
        do {
            System.out.println(node.val);
            node = node.next;
        } while (node != null);
    }

}
